package xcmg.device.dao.mapper.materialsSchedule;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xcmg.device.dao.entity.materialsSchedule.MaterialsScheduleDetailDO;

import java.math.BigDecimal;
import java.util.List;
@Mapper
public interface MaterialsScheduleDetailMapper {
    int delete(@Param("id") String id);

    int deleteByMainId(@Param("id") String id);

    int add(MaterialsScheduleDetailDO record);

    MaterialsScheduleDetailDO selectByPrimaryKey(String id);

    MaterialsScheduleDetailDO findByOrderAndMaterialNo(@Param("materialsScheduleId")String materialsScheduleId,@Param("materialsNo")String materialsNo);

    int update(MaterialsScheduleDetailDO record);

    //批量删除
    int remove(@Param("ids") List<String> ids);

    List<MaterialsScheduleDetailDO> list(@Param("materialsScheduleId") String materialsScheduleId);

    List<MaterialsScheduleDetailDO> listForLocationUser(@Param("materialsScheduleId") String materialsScheduleId);

    int updateInStatus(@Param("status") int status, @Param("billNo") String billNo,@Param("materialsNo") String materialsNo);

    int updateOutStatus(@Param("status") int status, @Param("billNo") String billNo,@Param("materialsNo") String materialsNo);

    int updatePostAmount(@Param("billId") String billId, @Param("materialNo")String materialNo, @Param("voucherNo")String voucherNo);

    //从生产领料（领入）的单据，更新pms端的领入过账信息
    int updatePickInPmsInfo(@Param("billId") String billId, @Param("materialNo")String materialNo,@Param("postInVoucherNo")String postInVoucherNo,
                             @Param("voucherNo") String voucherNo,@Param("postAmount") BigDecimal postAmount,@Param("postInStatus") Integer postInStatus);
    //从备件领料（领出）的单据，更新pms端的领出过账信息
    int updatePickOutPmsInfo(@Param("billId") String billId, @Param("materialNo")String materialNo,@Param("postOutVoucherNo") String postOutVoucherNo,
                         @Param("voucherNo") String voucherNo,@Param("postAmount") BigDecimal postAmount,@Param("postOutStatus") Integer postOutStatus);

    //从备件领料（领出）的单据，更新sap端的领入过账信息
    int updatePickOutSapInfo(@Param("id") String id,@Param("postInVoucherNo")String postInVoucherNo,@Param("postInStatus") Integer postInStatus);
    //从生产领料（领入）的单据，更新sap端的领出过账信息
    int updatePickInSapInfo(@Param("id") String id, @Param("postOutVoucherNo")String postOutVoucherNo,@Param("postOutStatus") Integer postOutStatus);

    int findPostStatus(@Param("billId")String billId);

    //过账时更新数据需要的查询，只返回需要的字段
    List<MaterialsScheduleDetailDO> listForPostUpdate(@Param("billId") String materialsScheduleId);

    int updatePostStatus(@Param("billId")String billId, @Param("postStatus")int postStatus);

    int updateVoucherNoNone(@Param("billId")String billId, @Param("materialsNo") String materialsNo);
}